/******************* 公共变量 *******************/
var userId = core.getUrlData('user_id');

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		bank: '',
		name: '',
		setCardNum: '',
		confirmCardNum: ''
	},
	methods: {
		checkPw: function (event) {
			var $this = $(event.target),
				thisIndex = $this.parent().index(),
				thisVal = $this.val();
			if (thisIndex == 1) {
				if (thisVal == '') {
					core.layerHint('银行名称不可为空');
				}
			} else if (thisIndex == 2) {
				if (thisVal == '') {
					core.layerHint('持卡人姓名不可为空');
				}
			} else {
				if (thisVal) {
					if (thisVal.match(/\d{6}/)) {
						if (thisIndex == 4) {
							if (thisVal != this.setCardNum) {
								core.layerHint('两次输入的卡号不一致，请重新输入');
							}
						} else {
							if (thisVal != this.confirmCardNum) {
								core.layerHint('两次输入的卡号不一致，请重新输入');
							}
						}
					} else {
						core.layerHint('请输入6位纯数字卡号');
					}
				} else {
					core.layerHint('输入卡号不可为空');
				}
			}
		},
		submit: function () {
			if (this.bank) {
				if (this.name) {
					if (this.setCardNum == this.confirmCardNum) {
						$.ajax({
							url: userVerifyPwUrl,
							type: 'post',
							data: {
								user_id: userId,
								bank_name: this.bank,
								z_name: this.name,
								tail_num: this.setCardNum,
								tail_nums: this.confirmCardNum
							},
							success: function (data) {
								console.log(data)
								
								if (data.status == 1) {
									core.hintHref(data.message, userUrl);
								} else {
									core.layerHint(data.message);
								}
							}
						})
					} else {
						core.layerHint('两次输入的卡号不一致，请重新输入');
					}
				} else {
					core.layerHint('持卡人姓名不可为空');
				}
			} else {
				core.layerHint('银行名称不可为空');
			}
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		
	},
	mounted: function () {
		common.bindBack();
	},
	updated: function () {
		
	}
});